#include "comm.hpp"
#include <unistd.h>
int main()
{

    key_t key = GetKey();
    // 获取物理内存
    int shmid = GetShm(key);

    // 挂载
    char *s = (char *)shmat(shmid, nullptr, 0);

    //open
    int fd = open(filename.c_str(), O_WRONLY, 0664);
    // 打印字母
    int pos = 0;
    for (char c = 'a'; c <= 'z'; c++)
    {
        s[pos++] = c;
        std::cout << "write#" << c << "......" << std::endl;
        sleep(1);
        write(fd,&pos,sizeof pos);
    }
    // 取消关联
    shmdt(s);
    close(fd);
    // std::cout << "取消挂载" << std::endl;

    return 0;
}